home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / term-source.lha / Extras / Source / gtlayout-Source.lha / LT_DeleteHandle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-31  |  3.3 KB  |  176 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. VOID __regargs
  10. LTP_DisposeGadgets(struct LayoutHandle *Handle)
  11. {
  12.     if(Handle -> List)
  13.     {
  14.         struct Gadget    *Gadget;
  15.         ObjectNode    *Node;
  16.  
  17.         if(Handle -> Window)
  18.             RemoveGList(Handle -> Window,Handle -> List,(UWORD)-1);
  19.  
  20.         Gadget = Handle -> List;
  21.  
  22.         if(Handle -> ExitFlush)
  23.         {
  24.             while(Gadget)
  25.             {
  26.                 if(GETOBJECT(Gadget,Node))
  27.                 {
  28.                     LTP_PutStorage(Node);
  29.  
  30.                     LTP_DeleteObjectNode(Handle,Node);
  31.                 }
  32.  
  33.                 Gadget = Gadget -> NextGadget;
  34.             }
  35.         }
  36.         else
  37.         {
  38.             while(Gadget)
  39.             {
  40.                 if(GETOBJECT(Gadget,Node))
  41.                     LTP_DeleteObjectNode(Handle,Node);
  42.  
  43.                 Gadget = Gadget -> NextGadget;
  44.             }
  45.         }
  46.  
  47.         FreeGadgets(Handle -> List);
  48.  
  49.         Handle -> List = NULL;
  50.     }
  51.  
  52. #ifdef DO_BOOPSI_KIND
  53.     if(Handle -> BOOPSIList)
  54.     {
  55.         struct Gadget *gadget = (struct Gadget *)Handle -> BOOPSIList,*next;
  56.         ObjectNode *Node;
  57.  
  58.         if(Handle -> Window)
  59.             RemoveGList(Handle -> Window,(struct Gadget *)Handle -> BOOPSIList,(UWORD)-1);
  60.  
  61.         while(gadget)
  62.         {
  63.             next = gadget -> NextGadget;
  64.  
  65.             if(GETOBJECT(gadget,Node))
  66.             {
  67.                 DisposeObject(gadget);
  68.  
  69.                 if(Node -> Special . BOOPSI . ClassBase)
  70.                 {
  71.                     CloseLibrary(Node -> Special . BOOPSI . ClassBase);
  72.  
  73.                     Node -> Special . BOOPSI . ClassBase = NULL;
  74.                 }
  75.  
  76.                 if(Node -> Special . BOOPSI . ClassTags)
  77.                 {
  78.                     FreeTagItems(Node -> Special . BOOPSI . ClassTags);
  79.  
  80.                     Node -> Special . BOOPSI . ClassTags = NULL;
  81.                 }
  82.  
  83.                 Node -> Host = NULL;
  84.             }
  85.  
  86.             gadget = next;
  87.         }
  88.  
  89.         Handle -> BOOPSIList = NULL;
  90.         Handle -> BOOPSIPrevious = NULL;
  91.     }
  92. #endif    /* DO_BOOPSI_KIND */
  93. }
  94.  
  95.  
  96. /*****************************************************************************/
  97.  
  98.  
  99. VOID LIBENT
  100. LT_DeleteHandle(REG(a0) LayoutHandle *Handle)
  101. {
  102.     if(Handle)
  103.     {
  104.         UnlockPubScreen(NULL,Handle -> PubScreen);
  105. #ifdef DO_CLONING
  106.         if(Handle -> CloneExtra)
  107.         {
  108.             if(Handle -> CloneExtra -> Screen)
  109.                 ScreenToBack(Handle -> CloneExtra -> Screen);
  110.         }
  111. #endif
  112.         LTP_DisposeGadgets(Handle);
  113.  
  114.         LT_UnlockWindow(Handle -> Parent);
  115.  
  116.         if(Handle -> Window)
  117.         {
  118.             LT_DeleteWindowLock(Handle -> Window);
  119.  
  120.             if(Handle -> MsgPort && Handle -> Window -> UserPort)
  121.             {
  122.                 struct IntuiMessage    *intuiMsg;
  123.                 struct Node        *next;
  124.  
  125.                 Forbid();
  126.  
  127.                 intuiMsg = (struct IntuiMessage *)Handle -> Window -> UserPort -> mp_MsgList . lh_Head;
  128.  
  129.                 while(next = intuiMsg -> ExecMessage . mn_Node . ln_Succ)
  130.                 {
  131.                     if(intuiMsg -> IDCMPWindow == Handle -> Window)
  132.                     {
  133.                         Remove(intuiMsg);
  134.  
  135.                         ReplyMsg(intuiMsg);
  136.                     }
  137.  
  138.                     intuiMsg = (struct IntuiMessage *)next;
  139.                 }
  140.  
  141.                 Handle -> Window -> UserPort = NULL;
  142.  
  143.                 ModifyIDCMP(Handle -> Window,NULL);
  144.  
  145.                 Permit();
  146.             }
  147.  
  148.             ClearMenuStrip(Handle -> Window);
  149.             CloseWindow(Handle -> Window);
  150.         }
  151.  
  152. #ifdef DO_MENUS
  153.         LT_DisposeMenu(Handle -> Menu);
  154. #endif    // DO_MENUS
  155.  
  156.         DisposeObject(Handle -> AmigaGlyph);
  157.         DisposeObject(Handle -> CheckGlyph);
  158.  
  159.         FreeScreenDrawInfo(Handle -> Screen,Handle -> DrawInfo);
  160.  
  161.         FreeVisualInfo(Handle -> VisualInfo);
  162.  
  163.         if(Handle -> RPort . Font && Handle -> CloseFont)
  164.             CloseFont(Handle -> RPort . Font);
  165. #ifdef DO_CLONING
  166.         if(Handle -> CloneExtra)
  167.         {
  168.             if(Handle -> CloneExtra -> Screen)
  169.                 CloseScreen(Handle -> CloneExtra -> Screen);
  170.         }
  171. #endif
  172.  
  173.         AsmDeletePool(Handle -> Pool,SysBase);
  174.     }
  175. }
  176.